package com.he.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.he.entity.Areas;
import com.he.service.AreasService;
import com.he.mapper.AreasMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author a'abc
* @description 针对表【areas】的数据库操作Service实现
* @createDate 2025-07-29 11:46:00
*/
@Service
public class AreasServiceImpl extends ServiceImpl<AreasMapper, Areas>
    implements AreasService{

    @Resource
    AreasMapper areasMapper;

    @Override
    public List<Areas> getProvinces() {
        QueryWrapper<Areas> wrapper = new QueryWrapper<>();
        wrapper.eq("level",1);
        return this.list(wrapper);
    }

    @Override
    public List<Areas> getCities(Integer provinceId) {
        QueryWrapper<Areas> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id",provinceId);
        return this.list(wrapper);
    }

    @Override
    public Areas getByCode(String code) {
        QueryWrapper<Areas> wrapper = new QueryWrapper<>();
        wrapper.eq("code",code);
        return this.getOne( wrapper);
    }
}




